/*
 * Copyright (c) 2023 Huawei Technologies Co., Ltd.
 * openUBMC is licensed under Mulan PSL v2.
 * You can use this software according to the terms and conditions of the Mulan PSL v2.
 * You may obtain a copy of Mulan PSL v2 at:
 *         http://license.coscl.org.cn/MulanPSL2
 * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
 * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
 * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
 * See the Mulan PSL v2 for more details.
 */

#ifndef GEN_CHIP_INTERFACE_H
#define GEN_CHIP_INTERFACE_H

#include <device_tree/base.h>

namespace dev::gen {

class MC_API Chip : public mc::engine::interface<Chip> {
public:
    MC_INTERFACE("bmc.dev.Chip")

    property<uint32_t> Address;
    property<uint8_t>  OffsetWidth;
    property<uint8_t>  AddrWidth;
    property<uint32_t> WriteTmout;
    property<uint32_t> ReadTmout;
    property<uint8_t>  RwBlockSize;
    property<uint8_t>  WriteInterval;
    property<uint8_t>  ReadInterval;
    property<uint8_t>  WriteRetryTimes;
    property<uint8_t>  ReadRetryTimes;

    virtual std::vector<uint8_t> BitIORead(uint32_t offset, uint8_t length, uint32_t mask);
    virtual void                 BitIOWrite(uint32_t offset, uint8_t length, uint32_t mask,
                                            const std::vector<uint8_t>& buffer);
    virtual std::vector<uint8_t> BlockIORead(uint32_t offset, uint32_t length);
    virtual void                 BlockIOWrite(uint32_t offset, const std::vector<uint8_t>& buffer);
    virtual std::vector<uint8_t> BlockIOWriteRead(const std::vector<uint8_t>& indata,
                                                  uint32_t                    read_length);
    virtual std::vector<uint8_t> BlockIOComboWriteRead(uint32_t                    write_offset,
                                                       const std::vector<uint8_t>& write_buffer,
                                                       uint32_t read_offset, uint32_t read_length);
};
} // namespace dev::gen

#endif // GEN_CHIP_INTERFACE_H